import { constantRoutes, ActiveRouter } from '@/router'

const state = {
    // 默认为静态路由
    routes: constantRoutes
}

const mutations = {
    setRoutes(state, payload) {
        state.routes = [...constantRoutes, ...payload]
    }

}

const actions = {
    getRoutes(context, mute) {
        // 遍历拿到用户所拥有的页面权限
        let res = ActiveRouter.filter(item => mute.includes(item.name))
        context.commit('setRoutes', res)
        // console.log(res);

        return res
    }

}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}